package br.com.californiahotel.client.architecture.viewController;

import br.com.californiahotel.client.architecture.viewController.MaintenanceController.MaintenanceDisplay;

import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import com.smartgwt.client.widgets.toolbar.ToolStripButton;

public abstract class MaintenanceView extends BasicView implements MaintenanceDisplay {

	private ListGrid listGrid;
	private ToolStripButton toolStripSaveButton;
	private ToolStripButton toolStripEditButton;
	private ToolStripButton toolStripDeleteButton;

	public MaintenanceView() {
		mountPanel();
		setWidth100();
		setHeight100();
		setMargin(20);
	}

	protected void mountPanel() {
		mountGridPanel();
	}

	private void mountGridPanel() {
		ToolStrip toolStrip = newToolStrip();

		listGrid = new ListGrid();
		listGrid.setWidth100();
		listGrid.setHeight(350);
		mountGrid();

		addMember(toolStrip);
		addMember(listGrid);
	}

	protected ToolStrip newToolStrip() {
		ToolStrip toolStrip = new ToolStrip();
		toolStrip.setWidth100();

		toolStripSaveButton = new ToolStripButton("Novo");
		toolStripEditButton = new ToolStripButton("Editar");
		toolStripDeleteButton = new ToolStripButton("Excluir");

		toolStrip.addButton(toolStripSaveButton);
		toolStrip.addButton(toolStripEditButton);
		toolStrip.addButton(toolStripDeleteButton);
		return toolStrip;
	}

	protected abstract void mountGrid();


	@Override
	public ToolStripButton getDeleteButton() {
		return toolStripDeleteButton;
	}

	@Override
	public ToolStripButton getEditButton() {
		return toolStripEditButton;
	}

	@Override
	public ListGrid getGrid() {
		return listGrid;
	}

	@Override
	public ToolStripButton getNewButton() {
		return toolStripSaveButton;
	}

}
